# -*- coding: utf-8 -*-#

# -------------------------------------------------------------------------------
# Name:         find_best_params_of_ma_stragecy
# Description:  比较双均线策略不同参数的结果
# Author:       ylf
# Date:         8/28/21
# -------------------------------------------------------------------------------

import pandas as pd
from strategy import ma_strategy as ma
import data.stock as st


stock = '000607.XSHE'
data = st.get_csv_price(stock, '2017-01-01', '2021-01-01')


params = [5, 10, 20, 30, 60, 150]
list_df = []

# 比较不同参数对双均线策略带来的影响

for short in params:
    for long in params:
        if long > short:
            current_data = ma.ma_stragecy(
                data=data, short_windows=short, long_windows=long)
            temp_list = [short, long, current_data.iloc[-1]['sum_rate']]
            list_df.append(temp_list)

# 转换成dataframe进行直观的观看
df = pd.DataFrame(list_df, columns=['short', 'long', 'sum_rate'])
print(df)
